/*****************************************************************
 MYD Engine v0.1

 File: myd_input.h
 Created: 09/07/09
*****************************************************************/

#ifndef _INPUT_H
#define _INPUT_H

#include "system/myd_system.h"

namespace myd
{
	class MYD_API Input
	{
		/////////////////////////////////////////
		// TO-DO: Input has to be a singleton!!!!
		/////////////////////////////////////////

		protected:
			//keyboard buffers
			unsigned char KeyBuffer[256];
			unsigned char KeyPrevBuffer[256];
			unsigned char KeyEvent[256];

			//mouse position
			long m_alMouseScreenAbsPos[3];
			long m_alMouseRelPos[3];

			//mouse buttons
			unsigned char m_aucMouseBut[3];
			bool m_abMouseButClick[3];
			bool m_abButState[3];

			//update
			void UpdateMouse();
			void UpdateKeyboard();

			//constructor
			Input();

		public:
			enum
			{POS_X, POS_Y, POS_Z};

			enum MouseButton
			{MB_1, MB_2, MB_3};

			enum KeyState
			{KS_NONE, KS_DOWN, KS_UP};

			//destructor
			virtual ~Input();

			virtual bool Init() = 0;
			virtual void Update() = 0;
			virtual void Deinit() = 0;
		    
			//devices acquisition
			virtual void Acquire() = 0;
			virtual void Reacquire() = 0;
			virtual void Unacquire() = 0;

			void SetMousePos(long x, long y, long z);
			void EventClean();
			virtual void Reset();

			//accessors
			inline bool GetKeyDown(unsigned int uiKeyID);
			inline bool GetKeyEventDown(unsigned int uiKeyID);
			inline bool GetKeyEventUp(unsigned int uiKeyID);

			inline bool GetMouseBut(unsigned int uiButID);
			inline bool GetMouseClick(unsigned int uiButID);
			inline long GetMouseScrAbsPos(unsigned int uiButID);
			inline long GetMouseRelPos(unsigned int uiButID);
	};
	#include "myd_input.inl"
} // end namespace
#endif //MYD_INPUT_H
